<?php
class View_Admin_Packet extends View_Admin_Index_Template
{
    public $oTemp;
    
    public function displayPacketIndex($oModel)
    {
    	//$oModel->setData('display_menu',1);
        $this->initTemplate($oModel);
        if(MODE == "FO"){
            $this->oTemp->assign_file('tempMainContent', PATH_TEMPLATE_ADMIN .'html/fo_packet_index.html');
        }
        else{
            $this->oTemp->assign_file('tempMainContent', PATH_TEMPLATE_ADMIN .'html/packet_management_index.html');
        }
        
//        $this->oTemp->assign('pageHeding','TOP PAGE');
		$this->oTemp->assign('toobar_new', '?sMod=packet_index&sAction=add_new_form_packet');
        $this->oTemp->parse('main.toobar_new');
        $this->oTemp->assign('toobar_save',"$('frmUpdateCate').submit();");
        $this->oTemp->parse('main.toobar_save');
        if(MODE == "FO"){
            $array_packet = $oModel->listPacket();
            $this->oTemp->parse("main.buy_success");
        }
        else{
            $array_packet = $oModel->listPacket();
        }
        
        $i = 0;
        while($row = $array_packet->fetch_row()){
        	$i ++;
    		$row['no'] = $i;
            $row['css'] = "row" . ($i % 2);
            $row[image_thumb] = ($row[image]!="")?URL_UPLOAD_PACKET_THUMB.$row[image]:URL_UPLOAD_PRODUCT.'no_image.gif';
            $row[status] = ($row[status]== 1)?"active":"unactive";
        	$this->oTemp->assign('row', $row);
        	$this->oTemp->parse('main.rowPacket');
        }
    }
    public function addNewPacketForm($oModel){
    	$this->oTemp->assign_file('tempMainContent', PATH_TEMPLATE_ADMIN .'html/packet_mamagement_new.html');
//        $this->oTemp->assign('pageHeding','TOP PAGE');
		$sCancel =  '?sMod=packet_index';
        $this->oTemp->assign('toobar_save', 'check_packet_form()');
        $this->oTemp->parse('main.toobar_save');
        $this->oTemp->assign('toobar_cancel', $sCancel);
        $this->oTemp->parse('main.toobar_cancel');
        $this->oTemp->assign('action', 'do_add_new');
        $this->oTemp->parse('action');
    }
 	public function editPacketForm($oModel){
    	$this->oTemp->assign_file('tempMainContent', PATH_TEMPLATE_ADMIN .'html/packet_mamagement_new.html');
//        $this->oTemp->assign('pageHeding','TOP PAGE');
		$sCancel =  '?sMod=packet_index';
        $this->oTemp->assign('toobar_save', 'check_packet_form()');
        $this->oTemp->parse('main.toobar_save');
        $this->oTemp->assign('toobar_cancel', $sCancel);
        $this->oTemp->parse('main.toobar_cancel');
        $this->oTemp->assign('action', 'do_edit');
        $this->oTemp->parse('action');
        $array_packet = $oModel->getPacketById($_REQUEST[id]);
//        var_dump($array_packet);
        $this->oTemp->assign('row', $array_packet->fields);
    }
}